// @ts-ignore
/* eslint-disable */
import { request } from 'umi';
import { OrgBody, OrgItem } from '@/pages/Enterprise/Org/data';

export async function loadOrgList(param: OrgBody): Promise<{ data: OrgItem[] }> {
  return request('/v2/enterprise/org/list', { method: 'GET', params: param });
}

export async function loadOrgSelect(param: OrgBody): Promise<{ data: OrgItem[] }> {
  return request('/v2/enterprise/org/select', { method: 'GET', params: param });
}

export async function sensitiveTest(): Promise<{ data: OrgItem[] }> {
  return request('/v2/enterprise/train/plan/test', { method: 'GET' });
}

export async function loadOrg(orgId: number): Promise<{ data: OrgBody }> {
  return request(`/v2/enterprise/org/${orgId}`, { method: 'GET' });
}

export async function addOrg(param: OrgBody): Promise<{ data: number }> {
  return request('/v2/enterprise/org', { method: 'POST', data: param });
}

export async function updateOrg(param: OrgBody): Promise<{ data: number }> {
  return request('/v2/enterprise/org', { method: 'PUT', data: param });
}

export async function removeOrg(orgId: number) {
  return request<Record<string, any>>(`/v2/enterprise/org/${orgId}`, { method: 'DELETE' });
}
